package com.sysef.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.sysef.exception.DAOExcepcion;
import com.sysef.modelo.BeanTipoDocumento;
import com.sysef.util.ConexionBD;

public class DAOTipoDocumento extends BaseDAO {
	
	public BeanTipoDocumento obtenerTipoDocumentoxId(int intIdTipoDocu) throws DAOExcepcion {
		BeanTipoDocumento objBeanTipoDoc = new BeanTipoDocumento();
		Connection con = null;
		PreparedStatement stmt = null;
		ResultSet rs = null;
		try {
			String query = "select * from tb_tipodocumento where idTipoDoc =?";
			con = ConexionBD.obtenerConexion();
			stmt = con.prepareStatement(query);
			stmt.setInt(1, intIdTipoDocu);
			rs = stmt.executeQuery();
			if (rs.next()) {
				objBeanTipoDoc.setIntIdTipoDocumento(rs.getInt("idTipoDoc"));
				objBeanTipoDoc.setStrDescTipoDocumento(rs.getString("descTipoDoc"));
				
			}
		} catch (SQLException e) {
			System.err.println(e.getMessage());
			throw new DAOExcepcion(e.getMessage());
		} finally {
			this.cerrarResultSet(rs);
			this.cerrarStatement(stmt);
			this.cerrarConexion(con);
		}
		return objBeanTipoDoc;
	}

}
